/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package metier;

import java.sql.Date;
import java.text.DateFormat;
import java.util.*;

/*
 * @author epulapp
 * Classe de création de Personne avec différent attributs
 */
public class Personne {

    public static int cmp;
    private int pseudo;
    private String nom;
    private String prenom;
    private Date date_nais;
    private int amis[];
    private String[] centres_interet;
    private boolean visited;
    public int degre_celeb;
    private String centres_interet_concat;

    /*
     * Constructeur qui génère des attributs aléatoire à sa création
     */
    public Personne() {
        pseudo = cmp++;
        amis = new int[100];
        nom = GenerateMaj(1) + GenerateMin(5);
        prenom = GenerateMaj(1) + GenerateMin(5);
        date_nais = new Date(DateFormat.DEFAULT);
        visited = false;
        centres_interet = new String[12];
        centres_interet_concat ="";

      
        int j = 0;
        int index = 0;
        while (j < 5) {
           
            float i = (float) Math.random();
            
          
            if (i > 0.4) {
                centres_interet[index] = centres.setCentre(j);

            } else {
                centres_interet[index] = "";
            }
            centres_interet_concat+=centres_interet[index];
            index++;
            j++;
        }
       

    }

    public boolean isVisited() {
        return visited;
    }

    public void setVisited(boolean visited) {
        this.visited = visited;
    }


    /**
     * @param taille de la chaine
     * @return une chaine autogénéré de caractères (Minuscule)
     */
    public String GenerateMin(int length) {
        String chars = "abcdefghijklmnopqrstuvwxyz";
        String pass = "";
        for (int x = 0; x < length; x++) {
            int i = (int) Math.floor(Math.random() * 26);
            pass += chars.charAt(i);
        }
        return pass;
    }

    /**
     * @param taille de la chaine
     * @return une chaine autogénéré de caractères (Majuscule)
     */
    private String GenerateMaj(int length) {
        String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String pass = "";
        for (int x = 0; x < length; x++) {
            int i = (int) Math.floor(Math.random() * 26);
            pass += chars.charAt(i);
        }
        return pass;
    }

    public int getPseudo() {
        return pseudo;
    }

    /**
     * @param pseudo the pseudo to set
     */
    public void setPseudo(int pseudo) {
        this.pseudo = pseudo;
    }

    /**
     * @return the nom
     */
    public String getNom() {
        return nom;
    }
     public String getCentresConcat() {
        return centres_interet_concat;
    }

    /**
     * @param nom the nom to set
     */
    public void setNom(String nom) {
        this.nom = nom;
    }

    /**
     * @return the prenom
     */
    public String getPrenom() {
        return prenom;
    }

    /**
     * @param prenom the prenom to set
     */
    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    /**
     * @return the date_nais
     */
    public Date getDate_nais() {
        return date_nais;
    }

    /**
     * @param date_nais the date_nais to set
     */
    public void setDate_nais(Date date_nais) {
        this.date_nais = date_nais;
    }

    /**
     * @return the amis
     */
    public int[] getAmis() {
        return amis;
    }

    /**
     * @param amis the amis to set
     */
    public void setAmis(int amis) {
        int taille = this.amis.length;

    }

    public void addAmis(int amisAjout) {
        int i = 0;
        if (this.amis != null) {
            while (i < this.amis.length - 1) {
                if (this.amis[i] == 0) {
                    this.amis[i] = amisAjout;
                    break;
                }
                i++;
            }


            //System.out.println("ajout de l'ami "+i); , utilisé pour nos tests


        } else {
            //System.out.println("ajout de l'ami "+amisAjout); , utilisé pour nos tests
            this.amis[0] = amisAjout;
        }

    }

    /**
     * @return the centres_interet
     */
    public String getCentres_interet() {
        int i = 0;
        String chaine = "";
        while (i < centres.nombreCentreInteret) {
            if(centres_interet[i] == null) i++;
                    else{
            chaine = chaine + " | " + centres_interet[i];
            i++;
            }
        }
        return chaine;
    }

    public String getToutAmis() {
        String listeAmis = "";
        if (this.amis != null) {
            for (int i = 0; i < this.amis.length; i++) {
                if (this.amis[i] != 0) {
                    listeAmis += this.amis[i] + " | ";
                }

            }
        }
        return listeAmis;
    }

    public boolean estPasAmis(int chercheAmis) {

        if (this.amis != null) {
            for (int i = 0; i < this.amis.length; i++) {
                if (this.amis[i] == chercheAmis) {
                    return false;
                }
            }
        }

        return true;
    }

    /**
     * @param centres_interet the centres_interet to set
     */
    public void setCentres_interet(String[] centres_interet) {
        this.centres_interet = centres_interet;
    }

    /**
     * @return the degre_celeb
     */
    public int getDegre_celeb() {
        return degre_celeb;
    }

    /**
     * @param degre_celeb the degre_celeb to set
     */
    public void setDegre_celeb(int degre_celeb) {
        this.degre_celeb = degre_celeb;
    }
    
    public String[] getInteret()
    {
        return centres_interet;
    }
}
